﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tracy.DataModel;
using System.Xml;

namespace Tracy
{
    public class ResolutionProvider
    {
        List<Resolution> _resolutions = new List<Resolution>();

        public List<Resolution> Resolutions
        {
            get { return _resolutions; }
        }

        Dictionary<string, Resolution> _indexName = new Dictionary<string, Resolution>();
        public Resolution GetItem(string name)
        {
            if(_indexName.ContainsKey(name))
                return _indexName[name];
            return null;
        }

        public ResolutionProvider()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(@"Settings\Resolutions.xml");
            foreach(XmlElement resolutionNode in doc.SelectNodes("resolutions/resolution")){
                Resolution resolution = new Resolution(resolutionNode);
                Resolutions.Add(resolution);
                _indexName.Add(resolution.Name, resolution);
            }
        }
    }
}
